package com.zql.LeetCode;

import com.zql.baseEntity.ListNode;

/**
 * Created By ShuHua on 2021/8/26.
 */
public class HasCycle_141 {

    public boolean hasCycle(ListNode head) {
        if(head==null||head.next==null) return false;
        ListNode fast =head;
        ListNode slow =head;

        while(fast!=null&&fast.next!=null){

            slow=slow.next;
            fast=fast.next.next;
            if (slow==fast)return true;
        }
        return false;
    }
}
